//
//  ViewController.m
//  ZBTechniqueLibrary
//
//  Created by apple on 2018/9/29.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ViewController.h"
#import "ZBImageTextViewController.h"

static NSString *UITableViewCellID = @"UITableViewCellID";
@interface ViewController () <UITableViewDelegate, UITableViewDelegate>


@property (nonatomic, strong) NSMutableArray <NSDictionary *>*dataList;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"功能跳转";
   
}

#pragma mark - tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UITableViewCellID];
    if(cell == nil){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UITableViewCellID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if(indexPath.row < self.dataList.count){
        NSDictionary *keyValue = self.dataList[indexPath.row];
        cell.textLabel.text = [keyValue valueForKey:@"valueText"];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row < self.dataList.count){
        NSDictionary *keyValue = self.dataList[indexPath.row];
         NSString *classString = [keyValue valueForKey:@"keyVC"];
        Class  cls = NSClassFromString(classString);
        [self.navigationController pushViewController:[[cls alloc]init] animated:YES];
    }
   
}



#pragma mark - lazy
- (NSMutableArray<NSDictionary *> *)dataList
{
    if(_dataList == nil)
    {
        _dataList = [NSMutableArray array];
        NSString *path = [[NSBundle mainBundle] pathForResource:@"DemoViewController.plist" ofType:nil];
        
        if(path.length > 0){
            NSArray *arrays = [NSArray arrayWithContentsOfFile:path];
            [_dataList addObjectsFromArray:arrays];
        }
    }
    return _dataList;
}

@end
